package cn.johnyu.controller;

import cn.johnyu.mapper.ProductMapper;
import cn.johnyu.pojo.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class ProductController {
    @Autowired
    private ProductMapper productMapper;
    @GetMapping("/info")
    public String info(){
        return "my info: "+System.currentTimeMillis();
    }

    @GetMapping("/products")
    public ResponseEntity<List<Product>> findAllProducts(){
        return ResponseEntity.ok(productMapper.findAllProducts());
    }
}
